set :application, "crowd-control"
set :repository,  "http://crowd-control.googlecode.com/svn/trunk"

# If you aren't deploying to /u/apps/#{application} on the target
# servers (which is the default), you can specify the actual location
# via the :deploy_to variable:
# set :deploy_to, "/var/www/#{application}"
set :deploy_to, "/home/festival/www/demo.crowd-control.org.uk"
set :rails_env, "demo"
set :user, "festival"
set :use_sudo, false
set :first_mongrel_port, 9003

# If you aren't using Subversion to manage your source code, specify
# your SCM below:
# set :scm, :subversion

role :app, "alpha.arachsys.com"
role :web, "alpha.arachsys.com"
role :db,  "alpha.arachsys.com", :primary => true


namespace :deploy do
  task :start, :roles => :app do
    try_sudo "sh -c 'cd #{current_path} && nohup script/spin #{first_mongrel_port} #{rails_env}'"
  end

  task :restart, :roles => :app do
    run "ruby #{current_path}/script/process/reaper -a kill -r 'crowd-control.[0-9]*.pid'"
    try_sudo "sh -c 'cd #{current_path} && nohup script/spin #{first_mongrel_port} #{rails_env}'"
  end
end
 
task :restart_web_server, :roles => :web do
  run "/home/festival/lighttpd/restart"
end

after "deploy:start", :restart_web_server